package com.joysuch.wwyt.datadump.biz.model;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.zlg.common.datadump.annotation.DataDumpEntity;
import cn.zlg.common.datadump.annotation.DataDumpField;
import cn.zlg.common.springmvc.validate.constraints.NotNull;
import com.joysuch.wwyt.bp.entity.dsl.QBPNFCLocation;
import com.joysuch.wwyt.core.entity.dsl.QBaseTypeGroupItem;
import com.joysuch.wwyt.core.entity.dsl.QBaseUser;
import com.joysuch.wwyt.datadump.biz.convertor.*;
import com.joysuch.wwyt.datadump.biz.processor.EduQuestionImportProcessor;
import com.joysuch.wwyt.datadump.biz.processor.RiskPointImportProcessor;
import com.joysuch.wwyt.datadump.biz.query.RiskPointDumpQueryBean;
import com.joysuch.wwyt.risk.entity.dsl.QRiskDistrict;
import com.joysuch.wwyt.risk.entity.dsl.QRiskPoint;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Pattern;

/**
 * @Author ZhaoQiuWei
 * @Date 2021/10/26 11:13
 */
@DataDumpEntity(name = "risk-point-dump", entity = QRiskPoint.class, exportQueryConditions = RiskPointDumpQueryBean.class, importProcessors = RiskPointImportProcessor.class, businessName = "风险点", dynamicDataBizType = "riskPointManage", idField = "code", dynamicDataBizCode = "风险点编号")
@Data
public class RiskPointDumpBean {


    @DataDumpField(field = "id", importIgnore = true)
    private Long id;

    @NotNull(message = "风险单元编号不能为空")
    @Length(max = 30)
    @Excel(name = "风险单元编号", width = 20)
    @DataDumpField(field = "code", importKey = true)
    private String code;

    @NotNull(message = "风险单元名称不能为空")
    @Length(max = 128)
    @Excel(name = "风险单元名称", width = 20)
    @DataDumpField(field = "name")
    private String name;

    @Excel(name = "风险单元描述", width = 30)
    @Length(max = 512)
    @DataDumpField(field = "description")
    private String description;

    @NotNull(message = "风险单元类型不能为空")
    @Excel(name = "风险单元类型", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "type", importConvertors = ImportRiskPointTypeCodeConvertor.class, exportConvertors = ExportRiskPointTypeCodeConvertor.class)
    private String type;

    @Excel(name = "子类型", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "subType", exportConvertors = ExportRiskPointTypeCodeConvertor.class)
    private String subType;

    @Excel(name = "所属分析对象", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "riskDistrict.id", referenceEntity = QRiskDistrict.class, referenceEntityField = "name", importIgnore = true, needSetOtherEntity = true)
    private String districtName;

    @NotNull(message = "风险分析对象编号不能为空")
    @Excel(name = "分析对象编号", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "riskDistrict.id", referenceEntity = QRiskDistrict.class, referenceEntityField = "code", needSetOtherEntity = true)
    private String districtCode;

    @Excel(name = "所属岗位", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "dutyJobId", referenceEntity = QBaseTypeGroupItem.class, referenceEntityField = "name")
    private String dutyJobName;

    @Excel(name = "数量或活动频率", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "measureValue")
    private String measureValue;

    @Excel(name = "危害分析", width = 30)
    @Length(max = 512)
    @DataDumpField(field = "unstandardSituationConsequence")
    private String unstandardSituationConsequence;

    @Excel(name = "主要后果", width = 30)
    @Length(max = 512)
    @DataDumpField(field = "accidentType")
    private String accidentType;

    @Excel(name = "应急处置措施", width = 30)
    @Length(max = 512)
    @DataDumpField(field = "emergencyHandleMeasures")
    private String emergencyHandleMeasures;

    @Excel(name = "风险要素", width = 30)
    @Length(max = 64)
    @DataDumpField(field = "riskFactor", importConvertors = ImportRiskFactorConvertor.class, exportConvertors = ExportRiskFactorConvertor.class)
    private String riskFactor;

    @Excel(name = "安全警示标志", width = 30)
    @Length(max = 64)
    @Pattern(regexp = "指示标志|警示作业安全警示标志|逃生避难警示标志|风向警示标志|其他", message = "只能填写以下内容" + "\"指示标志|警示作业安全警示标志|逃生避难警示标志|风向警示标志|其他\"")
    @DataDumpField(field = "safeWarnMark")
    private String safeWarnMark;

    @NotNull(message = "排查签到方式不能为空")
    @Excel(name = "排查签到方式", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "signInMethod", importConvertors = ImportSignInMethodConvertor.class, exportConvertors = ExportSignInMethodConvertor.class)
    private String signInMethodStr;

    @Excel(name = "NFC卡设置（识别码）", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "nfc")
    private String nfc;

    @Excel(name = "辨识人员工号", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "identifyUserCodes")
    private String identifyUserCodes;

    @Excel(name = "责任人员工号", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "dutyUserId", referenceEntity = QBaseUser.class, referenceEntityField = "code")
    private String dutyUserCode;

    @NotNull(message = "审核人员工号不能为空")
    @Excel(name = "审核人员工号", width = 20)
    @Length(max = 64)
    @DataDumpField(field = "auditUserId", referenceEntity = QBaseUser.class, referenceEntityField = "code")
    private String auditUserCode;

    @Excel(name = "备注", width = 30)
    @Length(max = 512)
    @DataDumpField(field = "remark")
    private String remark;

}
